package com.shadow.mall.order.remote.dubbo;


import com.shadow.mall.common.core.JsonResult;
import com.shadow.mall.fulfill.api.FulfillApi;
import com.shadow.mall.fulfill.domain.request.CancelFulfillRequest;
import com.shadow.mall.order.exception.OrderBizException;
import com.shadow.mall.order.exception.OrderErrorCodeEnum;
import com.shadow.mall.order.remote.FulfillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 履约服务远程接口
 *
 * @version 1.0
 */
@Component
public class FulfillRemote {

//    @Autowired
//    private FulfillApi fulfillApi;
    private FulfillService fulfillService;

    /**
     * 取消订单履约
     * @param cancelFulfillRequest
     */
    public void cancelFulfill(CancelFulfillRequest cancelFulfillRequest) {
        JsonResult<Boolean> jsonResult = fulfillService.cancelFulfill(cancelFulfillRequest);
        if (!jsonResult.getSuccess()) {
            throw new OrderBizException(OrderErrorCodeEnum.CANCEL_ORDER_FULFILL_ERROR);
        }
    }
}